package com.hotstrip.demo;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@RequiredArgsConstructor
@RestController
public class HomeController {


    @GetMapping("/")
    public String index(HttpServletRequest request) throws UnknownHostException {
        InetAddress localHost = InetAddress.getLocalHost();
        String hostName = localHost.getHostName();
        log.info("访问了");
        try {
            int i = 10/0;
        } catch (Exception e) {
            log.error("出错了",e);

        }
        return "hello world " + hostName+ " "+ IpUtil.getIpAddr(request);
    }
}
